<template>
  <div>
    <ul>
      <li v-for="item in dataArr" :key="item.id">
        <img v-lazy="item.scene_pic_url" alt="" />
        <p>{{ item.title }}</p>
        <h4>{{ item.subtitle }}</h4>
        <h3>￥{{ item.price_info }}.00元</h3>
      </li>
    </ul>
    <!-- 分页 -->
    <van-pagination
      v-model="page"
      :page-count="totalPages"
      mode="simple"
      @change="changePage"
    />
  </div>
</template>

<script>
// 导入专题接口请求
import { getTopicData } from "@/utils/http";
export default {
  name: "Topic",
  props: [""],
  data() {
    return {
      page: 1, //当前页
      size: 10, //每页数据条数
      dataArr: [], //数据
      totalPages: 0, //总页数
    };
  },

  components: {},

  computed: {},

  created() {
    // 初始化调用接口
    this.changePage();
  },

  mounted() {},

  methods: {
    changePage() {
      console.log(this.page);
      getTopicData({
        page: this.page,
        size: this.size,
      }).then((res) => {
        console.log(res);
        const { data, totalPages, currentPage } = res.data.data;
        this.dataArr = data;
        this.page = currentPage;
        this.totalPages = totalPages;
      });
    },
  },
};
</script>
<style lang="less" scoped>
div {
  padding-bottom: 70px;
  /deep/.van-pagination__page-desc {
    display: none;
  }
}
img {
  width: 100%;
  display: block;
}
p {
  font-size: 21px;
}
h4 {
  font-size: 16px;
}
h3 {
  font-size: 14px;
}
</style>